package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserId      int     `gorm:"type:int;not null;comment:用户id"`
	OrderNum    string  `gorm:"type:varchar(50);comment:订单编号"`
	PayType     int     `gorm:"type:tinyint;comment:支付方式;1.支付宝 2.微信"`
	PaySumPrice float64 `gorm:"type:decimal(10,2);comment:支付金额"`
}

type OrderGood struct {
	gorm.Model
	OrderId   int     `gorm:"type:int;not null;comment:编号id"`
	GoodId    int     `gorm:"type:int;not null;comment:商品id"`
	GoodName  string  `gorm:"type:varchar(15);not null;comment:商品名称"`
	GoodNum   string  `gorm:"type:varchar(15);not null;comment:商品编号"`
	GoodPrice float64 `gorm:"type:decimal(10,2);not null;comment:商品单价"`
	Num       int     `gorm:"type:int;not null;comment:商品购买数量"`
}

func (o *Order) Create() error {
	return DB.Create(&o).Error
}

func (og *OrderGood) Create() error {
	return DB.Create(&og).Error
}
